﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Text;

public partial class topic_toupiao : Basic
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    private Topic2Vote dd;


    public Topic2Vote DD
    {
        get
        {
            if (dd != null)
            {
                return dd;
            }
            string id = Request["id"];
            string str = Pub.LoadData(jsonUrl + "/topic/TopicVoteList.ashx?typeid=" + id);
            dd = Newtonsoft.Json.JsonConvert.DeserializeObject<Topic2Vote>(str);
            return dd;
        }
    }

    public string Count
    {
        get
        {
            string id = Request["id"];
            if (string.IsNullOrEmpty(id))
            {
                return "";
            }
            return DD.lst.Sum(x => x.Count).ToString() ;
        }

    }

    public string NR
    {
        get
        {
            string[] yanse = new string[] { "hong", "lan", "huang", "lu" };

            string id = Request["id"];
            if (string.IsNullOrEmpty(id))
            {
                return "";
            }
            
         
            StringBuilder sb=new StringBuilder();
            long sum = DD.lst.Sum(x => x.Count);
            int i = 0;
            foreach (var c in DD.lst)
            {
                i++;
                sb.AppendLine("<li class=\"c1\">"+i+"."+c.Title+"</li>");
	            sb.AppendLine("<li class=\"c1\">"+c.Count+"</li>");
                string bl=((double)c.Count*100/sum).ToString("0.0");
	            sb.AppendLine("<li class=\"c2\"><span class=\"fl kuang\">"+bl+"%</span><div class=\"bili fl\"><div style=\"width:"+bl+"%\" class=\""+yanse[(i-1)%4]+"\"></div></div> <div class=\"clr\"></div></li>");
            }
            return sb.ToString();
        }
    }
}